package com.best.config;

import com.best.bean.Person;
import com.best.service.BookService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;


//配置类==配置文件
@Configuration  //告诉Spring这是一个配置类
//@ComponentScan value:指定要扫描的包
//excludeFilters = Filter[] : 指定扫描的时候按照什么规则排除哪些组件
//includeFilters = Filter[] : 指定扫描的时候只需要包含哪些组件
//FilterType.ASSIGNABLE_TYPE : 按照给定的类型
//FilterType.REGEX : 使用ASPECTJ表达式
//FilterType.REGEX : 使用正则指定
//FilterType.CUSTOM : 使用自定义规则


//@ComponentScan(value = "com.best")
//@ComponentScan(value = "com.best", excludeFilters = {
////        @ComponentScan.Filter(type= FilterType.ANNOTATION, classes = {Controller.class})
////})
//@ComponentScan(value = "com.best", includeFilters = {
//        @ComponentScan.Filter(type= FilterType.ANNOTATION, classes = {Controller.class})
//}, useDefaultFilters = false)
//@ComponentScan(value = "com.best", includeFilters = {
//        @ComponentScan.Filter(type= FilterType.ASSIGNABLE_TYPE, classes = {BookService.class})
//}, useDefaultFilters = false)
@ComponentScan(value = "com.best", includeFilters = {
        @ComponentScan.Filter(type= FilterType.REGEX, classes = {BookService.class})
}, useDefaultFilters = false)
public class MainConfig {

    //给容器中注册一个Bean;类型为返回值的类型，id默认是用方法名作为id
    @Bean(name = "person1")
    public Person person() {
        return new Person("lisi", 20);
    }
}
